package com.kotasoft.iip.serializer;

import java.text.SimpleDateFormat;

import org.codehaus.jackson.map.ObjectMapper;

public class Serializer {

	public String toString(Object value) {
		try {
			ObjectMapper mapper = buildObjectMapper();
			byte[] result = mapper.writeValueAsBytes(value);
			return new String(result);
		} catch (Exception ex) {
			throw new RuntimeException(ex);
		}
	}

	protected ObjectMapper buildObjectMapper() {
		ObjectMapper mapper = new ObjectMapper();
		mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd"));
		return mapper;
	}
}
